package com.activity.adapter;

import android.view.View;

import androidx.annotation.NonNull;

import com.activity.bean.CategoryBean;
import com.chad.library.adapter.base.BaseItemDraggableAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.apple.ddhr_new.R;

import java.util.List;

public class ItemDragAdapter extends BaseItemDraggableAdapter<CategoryBean, BaseViewHolder> {
    public ItemDragAdapter(List<CategoryBean> data) {
        super(R.layout.header_category, data);
    }

    public  DeleteListener  deleteListener ;
    @Override
    protected void convert(@NonNull BaseViewHolder helper, CategoryBean item) {
        helper.setText(R.id.tv_name,item.getWorkscategoryname());

    }

    @Override
    public void onBindViewHolder(BaseViewHolder holder, int position) {
        super.onBindViewHolder(holder, position);
        holder.itemView.findViewById(R.id.tv_delete).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(deleteListener!=null){
                    deleteListener.itemClick(position);
                }
            }
        });
    }
    public  interface   DeleteListener{
        public void itemClick(int position);
    }
}
